{include_file name="Public/header" title="邮箱设置"}
		
		<!-- begin #content -->
		<div id="content" class="content">

			<!-- begin page-header -->
			<h1 class="page-header">邮箱设置</h1>
			<!-- end page-header -->


			<!-- begin row -->
			<div class="row">
                <!-- begin col-6 -->
				<div class="col-md-12 ">
					<!-- begin panel -->
					<div class="panel panel-inverse" data-sortable-id="form-stuff-2">
						<form action="{U('config/email')}" method="POST" class="margin-bottom-0">
						<div class="panel-body">


							<fieldset>

								<div class="form-group">
									<label>邮件显示名：</label>
									<input class="form-control" type="text" name="email[email_title]" value="{$email_config.email_title}" placeholder="如:GoCMS官方" datatype="*2-10" nullmsg="请填写邮件显示名" errormsg="请输入2-10个汉字或字符" />
									<span class="Validform_checktip"></span>
								</div>

								<div class="form-group">
									<label>邮箱服务器地址：</label>
									<input class="form-control" type="text" name="email[email_host]" value="{$email_config.email_host}" placeholder="如:smtp.163.com" datatype="url" nullmsg="请填写邮件服务器地址" errormsg="请输入合法的SMTP服务器地址" />
									<span class="Validform_checktip"></span>
								</div>

								<div class="form-group">
									<label>邮箱地址：</label>
									<input class="form-control" type="text" name="eamil[email_user]" value="{$email_config.email_user}" placeholder="如:gouguolei@163.com" datatype="e" nullmsg="请填写完整邮箱地址" errormsg="请输入合法的邮箱地址" />
									<span class="Validform_checktip"></span>
								</div>

								<div class="form-group">
									<label>邮箱密码：</label>
									<input class="form-control" type="password" name="email[email_password]" value="{$email_config.email_password}" datatype="s5-20" nullmsg="请填写邮箱密码" errormsg="请输入5-20个数字或字母" />
									<span class="Validform_checktip"></span>
								</div>

								<div class="form-group">
									<label>测试内容：</label>
									<input class="form-control js_test_content" type="text" value="这是测试邮件发送内容,请勿回复" datatype="*2-250" nullmsg="请填写测试内容" errormsg="请输入2-250个数字或字母" />
									<span class="Validform_checktip">该测试内容会发送到系统设置->网站设置里填写的系统邮箱里，请确保填写了系统邮箱</span>
								</div>


								<button type="submit" class="btn btn-sm btn-primary m-r-5 js_submit">保存设置</button>
								<button type="button" class="btn btn-sm btn-info m-r-5 js_test">测试发送</button>
							</fieldset>

						</div>
						</form>

						</div>
				</div>
					<!-- end panel -->
			</div>
                <!-- end col-6 -->
            <!-- end row -->
		</div>
		<!-- end #content -->

<script>
	$(function(){
		var demo=$("form").Validform({
			tiptype:function(msg,o,cssctl){

				if(!o.obj.is("form")){
					var objtip=o.obj.siblings(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}

			},
			label:"label",
			//ajaxPost:true,
		});

		//测试发送
		$(".js_test").click(function(){
            var thisObj = $(this);
			var url = "{U('config/email_test')}";
			var content = $(".js_test_content").val();
			if(content == ''){
				alert('测试内容不能为空');
				$(".js_test_content").focus();
				return false;
			}
            thisObj.attr("disabled", "disabled").text('发送中..');
			$.post(url , { content:content }, function(data){
				if(data.status){
                    thisObj.attr("disabled", "disabled").text('发送成功');
                    showToast('测试内容发送成功',2);

				}else{
                    thisObj.text('重新发送').removeAttr("disabled");
					alert(data.msg);
				}
			}, 'json').error(function(){
                thisObj.text('重新发送').removeAttr("disabled");
                showToast('测试内容发送错误，请检查邮箱配置是否正确',3);
			});
		});

	});
</script>
{include_file name="Public/footer"}